<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js"></script>
</head>

<body>
    <button id="get">get</button>
    <button id="post">post</button>
    <button id="jsonp">jsonp</button>

    <script>
        $('#post').on('click', () => {
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1/api/post",
                data: {
                    name: "1",
                    age: 2
                },
                success: (res) => {
                    console.log(res)
                }
            })
        })

        $('#get').on('click', () => {
            $.ajax({
                type: "GET",
                url: "http://127.0.0.1/api/get",
                data: {
                    name: "1",
                    age: 2
                },
                success: (res) => {
                    console.log(res)
                }
            })
        })

        $('#jsonp').on('click', () => {
            $.ajax({
                type: "GET",
                dataType: "jsonp",
                url: "http://127.0.0.1/api/jsonp",
                success: (res) => {
                    console.log(res)
                }
            })
        })
    </script>
</body>

</html>